<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>正方体旋转</title>
    <script src="js/vue.js"></script>
    <style>
        #app {
            perspective: 500px;
        }

       .box {
            width: 200px;
            height: 200px;
            margin: 100px auto;
            position: relative;
            transform: rotateX(360deg);
            transition: 6s;
            transform-style: preserve-3d;
            transform-origin: center center 100px;
        }

       .box div {
            width: 100%;
            height: 100%;
            position: absolute;
            top: 0;
            left: 0;
            opacity: .8;
        }

       .back {
            background-color: black;
        }

       .left {
            background-color: blue;
            transform: rotateY(-90deg);
            transform-origin: left;
        }

       .right {
            background-color: aqua;
            transform: rotateY(90deg);
            transform-origin: right;
        }

       .top {
            background-color: greenyellow;
            transform: rotateX(90deg);
            transform-origin: top;
        }

       .bottom {
            background-color: blueviolet;
            transform: rotateX(-90deg);
            transform-origin: bottom;
        }

       .front {
            background-color: red;
            transform: translateZ(200px);
        }
    </style>
</head>

<body>
    <div id='app'>
        <div class="box" :style="{ transform: 'rotateX(' + cubRotation + 'deg)' }">
            <div class="back"></div>
            <div class="left"></div>
            <div class="right"></div>
            <div class="top"></div>
            <div class="bottom"></div>
            <div class="front"></div>
        </div>
        <button @click="rotateCube">加一圈</button>
    </div>
    <script>
        const app = Vue.createApp({
            data() {
                return {
                    cubRotation: 0
                }
            },
            methods: {
                rotateCube() {
                    this.cubRotation += 360;
                }
            }
        }).mount('#app');
    </script>
</body>

</html>    